home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
local
/
serverAccess.php
< prev
next >
Wrap
PHP Script
|
2010-05-19
|
10KB
|
288 lines
<?php
/**
* Application and server connection test
*
*
* PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category NA
* @package NA
* @author Nicolas Bruley / Peer 2 World <contact@weezo.net>
* @copyright 2005-2009 Nicolas Bruley / Peer 2 World
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
* @link http://www.weezo.net
* @since File available since Release 1.0.0
*/
// Initialize script data
require_once('localFunctions.php');
lfInit();
$steps=array(0=>array('icon'=>'ok'),1=>array('icon'=>'v'),2=>array('icon'=>'v'));
if(!isset($_GET['step']) && !isset($_POST['step'])) die('missing argument');
if(isset($_POST['step'])) $step=$_POST['step']; else $step=$_GET['step'];
if(isset($_POST['silent'])) $_GET['silent']=$_POST['silent'];
// APPLICATION OUT ERROR
if($step=='appOutError'){
$steps[0]['icon']='alert';
$steps[0]['message']=cfCaption('accessTestAppNok');
$steps[0]['messageType']='error';
$steps[1]['message']=cfCaption('accessNotTested');
$steps[2]['message']=cfCaption('accessNotTested');
$leftIcon='alertBig';
$leftMessage=cfCaption('genError');
$button1=outButton(cfCaption('genRetry'),'close:restart',outIcon('go'));
$button2=outButton(cfCaption('genAbandon'),'javascript:wl.UICommand(\'close\')',outIcon('cancel'));
$error=true;
}
// APPLICATION OUT OK
elseif($step=='appOutOk'){
$steps[0]['icon']='ok';
$steps[0]['message']='<b>'.cfCaption('genOK').'</b>';
$steps[0]['messageType']='ok';
$steps[1]['icon']='go';
$steps[1]['message']=cfCaption('accessTesting');
$steps[1]['messageType']='progress';
$steps[2]['message']=cfCaption('accessNotTested');
$leftIcon='loadingBig';
$leftMessage=cfCaption('accessTesting');
$nextStep='serverOutTest';
$button1=outButton(cfCaption('genAbandon'),'javascript:wl.UICommand(\'close\')',outIcon('cancel'));
}
elseif($step=='serverOutTest'){
// Check outgoing server connection by opening a socket and HTTP connection to weezo.net server
cfAsyncHeader();
if (cfSocketHTTPRequest(DNS_SITE.'/portCheck.php')){
echo cfAsyncXMLJSaction('document.location="/local/serverAccess.php?step=serverOutOk&silent='.((@$_GET['silent'])?1:0).'";');
}
else{
echo cfAsyncXMLJSaction('document.location="/local/serverAccess.php?step=serverOutError&silent='.((@$_GET['silent'])?1:0).'";');
}
echo cfAsyncFooter();
exit;
}
// SERVER OUT OK
elseif($step=='serverOutOk'){
$steps[0]['icon']='ok';
$steps[0]['message']='<b>'.cfCaption('genOK').'</b>';
$steps[0]['messageType']='ok';
$steps[1]['icon']='ok';
$steps[1]['message']='<b>'.cfCaption('genOK').'</b>';
$steps[1]['messageType']='ok';
if(cfGGetVar('serverPort')<80){
$steps[2]['icon']='unknown';
$steps[2]['message']=cfCaption('startPortsTested','<b>'.cfGGetVar('serverPort').'</b>');
$steps[2]['messageType']='error';
$leftIcon='unknownBig';
$leftMessage=cfCaption('accessNotTested');
$button1=outButton(cfCaption('genOK'),'javascript:wl.UICommand(\'close\')',outIcon('ok'));
}
else{
$steps[2]['icon']='go';
$steps[2]['message']=cfCaption('accessTesting');
$leftIcon='loadingBig';
$leftMessage=cfCaption('accessTesting');
$nextStep='serverInTest';
$button1=outButton(cfCaption('genAbandon'),'javascript:wl.UICommand(\'close\')',outIcon('cancel'));
}
}
// SERVER OUT ERROR
elseif($step=='serverOutError'){
$steps[0]['icon']='ok';
$steps[0]['message']='<b>'.cfCaption('genOK').'</b>';
$steps[0]['messageType']='ok';
$steps[1]['icon']='alert';
$steps[1]['message']=cfCaption('accessTestHttpdOutNok');
$steps[1]['messageType']='error';
$steps[2]['message']=cfCaption('accessNotTested');
$leftIcon='alertBig';
$leftMessage=cfCaption('genError');
$button1=outButton(cfCaption('genRetry'),'javascript:reload(\'appOutOk\')',outIcon('go'));
$button2=outButton(cfCaption('genAbandon'),'javascript:wl.UICommand(\'close\')',outIcon('cancel'));
$error=true;
}
// SERVER IN
elseif($step=='serverInTest'){
$data=cfSocketHTTPRequest(DNS_SITE.'/portCheck.php?lng=en&port='.cfGGetVar('serverPort').'&v='.cfGGetVar('appVersion'));
cfAsyncHeader();
if(strpos($data,'RESULT=OK')!==false) {
// Check for wrong LAN IP found by weezo.net server
if(strpos($data,'LANIP=')!==false && strpos($data,'LANIP='.cfGGetVar('LANIPComputed'))===false)
echo cfAsyncXMLJSaction('document.location="/local/serverAccess.php?step=serverInError&silent='.((@$_GET['silent'])?1:0).'";');
// All OK
else
echo cfAsyncXMLJSaction('document.location="/local/serverAccess.php?step=serverInOk&silent='.((@$_GET['silent'])?1:0).'";');
}
else echo cfAsyncXMLJSaction('document.location="/local/serverAccess.php?step=serverInError&silent='.((@$_GET['silent'])?1:0).'";');
echo cfAsyncFooter();
exit;
}
// SERVER IN OK
elseif($step=='serverInOk'){
$steps[0]['icon']='ok';
$steps[0]['message']='<b>'.cfCaption('genOK').'</b>';
$steps[0]['messageType']='ok';
$steps[1]['icon']='ok';
$steps[1]['message']='<b>'.cfCaption('genOK').'</b>';
$steps[1]['messageType']='ok';
$steps[2]['icon']='ok';
$steps[2]['message']='<b>'.cfCaption('genOK').'</b>';
$steps[2]['messageType']='ok';
$leftIcon='okBig';
$leftMessage=cfCaption('genOK');
$button2=outButton(cfCaption('genOK'),'javascript:wl.UICommand(\'close:ok\')',outIcon('ok'));
}
// SERVER IN ERROR
elseif($step=='serverInError'){
$steps[0]['icon']='ok';
$steps[0]['message']=cfCaption('genOK');
$steps[0]['messageType']='ok';
$steps[1]['icon']='ok';
$steps[1]['message']=cfCaption('genOK');
$steps[1]['messageType']='ok';
$steps[2]['icon']='alert';
$steps[2]['message']=cfCaption('accessTestHttpdInNok','<b>'.cfGGetVar('serverPort').'</b>');
$steps[2]['messageType']='error';
$leftIcon='alertBig';
$leftMessage=cfCaption('genError');
$button1=outButton(cfCaption('genRetry'),'javascript:reload(\'serverOutOk\')',outIcon('go'));
$button2=outButton(cfCaption('genAbandon'),'javascript:wl.UICommand(\'close\')',outIcon('cancel'));
$error=true;
}
/**
* Display page
*/
cfInsertHEAD(false);
echo '<meta width="650x480"></meta>';
echo '<meta title="Weezo - '.cfCaption('startTestServerAccess').'"></meta>';
echo '</head>';
echo '<body title="Weezo" width="650" height="480" oncontextmenu="return false;" '.((isset($nextStep))?'onload="window.setTimeout(\'goSubmit()\',500)" style="cursor:wait;">':'>');
?>
<script type="text/javascript">
function goSubmit(){
sendData("silent=<?php echo ((@$_GET['silent'])?1:0);?>&step="+document.forms.nextStep.step.value);
}
function reload(nStep){
window.location='<?php echo $_SERVER['PHP_SELF'];?>?step='+nStep+'&silent=<?php echo ((@$_GET['silent'])?1:0);?>';
}
function retry(nStep){
<?php
echo "document.body.style.cursor='wait';\n";
echo 'document.forms.nextStep.step.value=nStep;';
echo "goSubmit();";
echo "\n}\n";
echo "</script>\n";
echo '<table class="frame1"><tr><td style="vertical-align:top; text-align:center; width:80px;padding-right:10px;height:100%">';
// Left icon
echo '<div class="frame1Header">'.cfCaption('genStatus','').'</div><br/>';
echo '<div style="border:1px solid #CCC;padding:7px; width:1px; margin-bottom:5px;">'.outImage(outIcon($leftIcon),false,'id="leftIcon"').'</div>';
if($leftMessage==cfCaption('genError')) echo '<div class="warning" style="font-weight:bold">'; else echo '<div>';
echo $leftMessage.'</div><br/><br/><br/>';
// UPnP information
echo '<div style="border:1px solid #CCC;padding:7px;width:1px; margin-bottom:5px;">'.outImage(outIcon('UPnP'),false,false).'</div>';
if(cfGGetVar('UPnPEnabled')){
echo '<div style="color:#2A2;font-weight:bold">'.cfCaption('genActivated').'</div>';
if(!cfGGetVar('UPnPMappingOK')) echo '<br/><span class="warning">'.outImage(outIcon('alert')).' '.cfCaption('UPnPFailed').'</span>';
}
else{
echo '<span class="warning" style="font-weight:bold">'.cfCaption('genActivatedFalse').'</span>';
}
echo '</td><td>';
// Right part
echo '<div class="frame1Header">'.cfCaption('genStep','').'</div><br/>';
for($i=0;$i<3;$i++){
echo outDivFrame('frame2',false,'width:540px');
echo '<div style="font-size:30px;float:left; margin-right:20px; margin-top:25px; padding-bottom:25px; margin-left:3px">'.($i+1).'. '.'</div>';
echo '<div class="frame2Header" style="width:100%;">'.outImage(outIcon($steps[$i]['icon']),false,false,'height:16px;width:16px;margin-right:7px;vertical-align:middle');
switch ($i) {
case 0:
echo cfCaption('accessTestAppOut');
echo outImage(outIcon('appOut'),false,false,'position:absolute;right:25px;');
break;
case 1:
echo cfCaption('accessTestHttpdOut');
echo outImage(outIcon('serverOut'),false,false,'position:absolute;right:25px;');
break;
case 2:
echo cfCaption('accessTestHttpdIn');
echo outImage(outIcon('serverIn'),false,false,'position:absolute;right:25px;');
break;
}
echo '</div>';
if(!isset($steps[$i]['messageType'])) echo '<div style="margin-left:79px;margin-top:3px">';
elseif($steps[$i]['messageType']=='error') echo '<div class="warning" style="margin-left:79px;margin-top:3px">';
elseif($steps[$i]['messageType']=='progress') echo '<div class="warning" style="color:#44F;margin-left:79px;margin-top:3px">';
elseif($steps[$i]['messageType']=='ok') echo '<div class="warning" style="color:#2C2;margin-left:79px;margin-top:3px">';
if(isset($steps[$i]['message'])) echo $steps[$i]['message']; else echo ' <br> ';
echo '</div></div></div><br/>';
}
echo '</td></tr></table>';
//if($buttons=='retryAppCancel') echo 1;
echo '<center>';
if(isset($button1)) echo $button1;
if(isset($button2)) echo '<span style="width:30px"> </span>'.$button2;
echo '</center>';
echo '<form name="nextStep" action="'.$_SERVER['PHP_SELF'].'" style="display:none"><input type="text" name="step" value="'.((isset($nextStep))?$nextStep:'').'"><input type="text" name="silent" value="'.((@$_GET['silent'])?1:0).'"></form>';
// If error, force form show (might have been launched hidden after an update)
if(@$error){
echo "<script type=\"text/javascript\">wl.UICommand('show')</script>";
}
if($step=='serverInOk' && @$_GET['silent']){
echo "<script type=\"text/javascript\">wl.UICommand('close')</script>";
}
?>
</body></html>